<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="150px">
      <el-form-item label="名称" prop="musicName">
        <el-input v-model="queryParams.musicName" placeholder="请输入名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="音乐家" prop="musicMaker">
        <el-input v-model="queryParams.musicMaker" placeholder="请输入音乐家" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <!--      <el-form-item label="顺序" prop="musicIndex">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.musicIndex"-->
      <!--          placeholder="请输入顺序"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!-- </el-form-item> -->
      <el-form-item label="级别" prop="ranks">
        <el-input v-model="queryParams.ranks" placeholder="请输入级别" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>


      <!-- <el-form-item label="乐谱可下载" prop="onlyVipDown">
        <el-select v-model="queryParams.onlyVipDown" clearable>
          <el-option label="是" value="1" />
          <el-option label="否" value="0" />
        </el-select>
      </el-form-item> -->


      <!--      <el-form-item label="曲目风格标签" prop="styleLabel">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.styleLabel"-->
      <!--          placeholder="请输入曲目风格标签"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->

      <!-- <el-form-item label="会员可见" prop="onlyVipShow">
        <el-select v-model="queryParams.onlyVipShow" clearable>
          <el-option label="是" value="1" />
          <el-option label="否" value="0" />
        </el-select>
      </el-form-item> -->

      <!-- <el-form-item label="评测师傅会员可用" prop="onlyTester">
        <el-select v-model="queryParams.onlyTester" clearable>
          <el-option label="是" value="1" />
          <el-option label="否" value="0" />
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="会员可下载" prop="onlyVipDown">
        <el-select v-model="queryParams.onlyVipDown" clearable>
          <el-option label="是" value="1" />
          <el-option label="否" value="0" />
        </el-select>
      </el-form-item> -->


      <!-- <el-form-item label="创作时间" prop="makeTime" style="margin-right: 11%;">
        <el-date-picker clearable v-model="queryParams.makeTime" type="date" value-format="yyyy-MM-dd"
          placeholder="请选择创作时间">
        </el-date-picker>
      </el-form-item> -->
      <!--      <el-form-item label="操作人" prop="operatorUser">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.operatorUser"-->
      <!--          placeholder="请输入操作人"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="操作时间" prop="operatorTime">-->
      <!--        <el-date-picker clearable-->
      <!--          v-model="queryParams.operatorTime"-->
      <!--          type="date"-->
      <!--          value-format="yyyy-MM-dd"-->
      <!--          placeholder="请选择操作时间">-->
      <!--        </el-date-picker>-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="音频" prop="musicWav">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.musicWav"-->
      <!--          placeholder="请输入音频"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="横屏json文件" prop="horizontalJson">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.horizontalJson"-->
      <!--          placeholder="请输入横屏json文件"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="竖屏json文件" prop="verticalJson">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.verticalJson"-->
      <!--          placeholder="请输入竖屏json文件"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="给SDK用的 musicxml" prop="musicForSdk">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.musicForSdk"-->
      <!--          placeholder="请输入给SDK用的 musicxml"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="横板封面" prop="horizontalImg">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.horizontalImg"-->
      <!--          placeholder="请输入横板封面"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="竖版封面" prop="verticalImg">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.verticalImg"-->
      <!--          placeholder="请输入竖版封面"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['system:musicinfo:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['system:musicinfo:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['system:musicinfo:remove']">删除</el-button>
      </el-col>
      <!--      <el-col :span="1.5">-->
      <!--        <el-button-->
      <!--          type="warning"-->
      <!--          plain-->
      <!--          icon="el-icon-download"-->
      <!--          size="mini"-->
      <!--          @click="handleExport"-->
      <!--          v-hasPermi="['system:musicinfo:export']"-->
      <!--        >导出</el-button>-->
      <!--      </el-col>-->




      <!-- <el-col :span="1.5"> -->
  <!-- Music Selection Modal -->
  <!-- <el-dialog v-if="isMusicSelectionModalOpen" title="Music Selection" @close="isMusicSelectionModalOpen = false">
    <el-form :model="fileSelectionForm" label-width="80px">
      <el-form-item label="选择文件上传">
        <el-select v-model="fileSelectionForm.selection" placeholder="请选择">
          <el-option label="是" value="yes" />
          <el-option label="否" value="no" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="confirmFileSelection">确定</el-button>
        <el-button @click="cancelFileSelection">取消</el-button>
      </el-form-item>
    </el-form>
  </el-dialog> -->

  <!-- File Upload Section -->
  <!-- <el-upload ref="uploadMusic" class="upload-demo" :action="upUrl" name="multipartFile" :on-change="onChangeFile"
    :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" :limit="2"
    :on-exceed="handleExceed" :on-success="hanldeSuccess" :headers="headers" :show-file-list="true"
    :auto-upload="true" :data="{ name: '小琴童' }">
    <el-button type="warning" plain icon="el-icon-upload" size="mini" @click="handleImportMusic"
      v-hasPermi="['system:musicinfo:importMusic']">导入曲目</el-button>
  </el-upload>
</el-col> -->
<!-- <el-col :span="1.5">
  <button @click="dialog">上传乐曲</button>
</el-col> -->
<!-- 初始隐藏 -->
      <el-col :span="1.5" >
       
        <!-- <el-upload ref="uploadMusic" class="upload-demo" :action="upUrl" name="multipartFile" :on-change="onChangeFile"
          :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" :limit="2"
          :on-exceed="handleExceed" :on-success="hanldeSuccess" :headers="headers" :show-file-list="true"
          :auto-upload="true" :data="{name:'小琴童'}">
          <el-button type="warning" plain icon="el-icon-upload" size="mini" @click="handleImportMusic"
            v-hasPermi="['system:musicinfo:importMusic']" >导入曲目</el-button>
        </el-upload> -->





        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdds">添加曲目
        </el-button>
      </el-col>


      <el-dialog :title="title" :visible.sync="opens" :close-on-click-modal="false" width="800px" append-to-body>
      <el-form :model="arrayUserInfo" ref="arrayUserInfo" size="small" :inline="true" label-width="68px">
        <el-form-item label="导入音乐" prop="multipartFile">
          <el-upload ref="uploadMusic" class="upload-demo" :action="upUrl" name="multipartFile" :on-change="onChangeFile"
          :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" :limit="2"
          :on-exceed="handleExceed" :on-success="hanldeSuccess" :headers="headers" :show-file-list="true"
          :auto-upload="true" :data="{name:userName}">
          <el-button type="warning" plain icon="el-icon-upload" size="mini" @click="handleImportMusic"
           >导入曲目</el-button>
        </el-upload>
        </el-form-item>

        <el-form-item label="用户选择" prop="onlyVipDown">
        <el-select v-model="arrayUserInfo.type" clearable>
          <el-option label="普通用户" value="01" />
          <el-option label="虚拟用户" value="02" />
        </el-select>
      </el-form-item>
      <el-button type="primary" plain  size="mini" @click="userInfo">确定
        </el-button>
      </el-form>

      <el-table v-loading="loading" :data="arrayUser" @selection-change="handleSelectionChanges">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="名称" align="center" prop="nickName">
          <!-- <span>{{ arrayUserInfo.type == 1? arrayUser[index].nickName : arrayUser[index].nickName + '（虚拟用户）' }}</span> -->
        </el-table-column>

      </el-table>
      <el-divider></el-divider>
      <el-button type="primary" @click="addToBookAction">确定</el-button>
    </el-dialog>

      <!-- <el-dialog
  title="提示"
  :visible.sync="isFlag"
  width="30%"
  :before-close="handleClose">
  <span>这是一段信息</span>
  <span slot="footer" class="dialog-footer">
    <el-button @click="isFlag = false">取 消</el-button>
    <el-button type="primary" @click="isFlag = false">确 定</el-button>
  </span>
</el-dialog> -->
           <!-- <el-col :span="1.5"> -->
             <!-- <el-upload
               class="upload-demo"
               :action="upUrl"
               name="file"
               :on-preview="handlePreview"
               :on-remove="handleRemove"
               :before-remove="beforeRemove"
               :limit="1"
               :on-exceed="handleExceed"
               :headers="headers"
               :show-file-list="true"
              :auto-upload ="true"
               > -->
               <!-- <el-button size="small" type="primary" @click="dialogVisible = true">用户选择</el-button> -->
             <!-- </el-upload> -->
             <!-- <el-dialog
  title="选择用户"
  :visible.sync="dialogVisible"
  width="30%"
  :before-close="handleClose">
  <span>这是一段信息</span>
  <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
</el-dialog> -->
           <!-- </el-col> -->

      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>



    <el-table v-loading="loading" :data="musicinfoList" @selection-change="handleSelectionChange" label-width="100px">
      <el-table-column type="selection" width="55" align="center" />
      <!--      <el-table-column label="主键id" align="center" prop="id" />-->
      <el-table-column label="名称" align="center" prop="musicName" width="150"/>
      <el-table-column label="音乐家" align="center" prop="musicMaker" />
      <el-table-column label="级别" align="center" prop="ranks" />
      <el-table-column label="顺序" align="center" prop="musicIndex" sortable=""/>
      <!--      <el-table-column label="封面" align="center" prop="img" />-->
      <el-table-column label="创作时间" align="center" prop="makeTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.makeTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <!--      <el-table-column label="曲目故事/简介" align="center" prop="musicDesc" />-->
      <!--      <el-table-column label="曲目风格标签" align="center" prop="styleLabel" />-->
      <!--      <el-table-column label="pdf乐谱" align="center" prop="pdfContent" />-->
      <el-table-column label="是否会员可见" align="center" prop="onlyVipShow" :formatter="vipshowFormatter" />
      <el-table-column label="乐谱是否会员可下载" align="center" prop="onlyVipDown" :formatter="vipdownFormatter" />
      <el-table-column label="是否评测是否会员可用" align="center" prop="onlyTester" :formatter="onlyTesterFormatter" />
      <!--      <el-table-column label="操作人" align="center" prop="operatorUser" />-->
      <!--      <el-table-column label="操作时间" align="center" prop="operatorTime" width="180">-->
      <!--        <template slot-scope="scope">-->
      <!--          <span>{{ parseTime(scope.row.operatorTime, '{y}-{m}-{d}') }}</span>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <!--      <el-table-column label="音频" align="center" prop="musicWav" />-->
      <!--      <el-table-column label="横屏json文件" align="center" prop="horizontalJson" />-->
      <!--      <el-table-column label="竖屏json文件" align="center" prop="verticalJson" />-->
      <!--      <el-table-column label="给SDK用的 musicxml" align="center" prop="musicForSdk" />-->
      <el-table-column label="横板封面" align="center" prop="horizontalImg">
        <template slot-scope="scope">
          <image-preview :src="scope.row.horizontalImg" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="竖版封面" align="center" prop="verticalImg">
        <template slot-scope="scope">
          <!-- {{ scope.row.verticalImg }} -->
          <image-preview :src="scope.row.verticalImg" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status" :formatter="statusFormatter" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-info" @click="handleView(scope.row)">查看</el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['system:musicinfo:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['system:musicinfo:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改乐曲信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="名称" prop="musicName">
          <el-input v-model="form.musicName" placeholder="请输入名称" />
        </el-form-item>
        <el-form-item label="音乐家" prop="musicMaker">
          <el-input v-model="form.musicMaker" placeholder="请输入音乐家" />
        </el-form-item>
        <el-form-item label="顺序" prop="musicIndex">
          <el-input v-model="form.musicIndex" placeholder="请输入顺序" />
        </el-form-item>
        <el-form-item label="级别" prop="ranks">
          <el-input v-model="form.ranks" placeholder="请输入级别-" />
        </el-form-item>
        <!--        <el-form-item label="封面" prop="img">-->
        <!--          <el-input v-model="form.img" placeholder="请输入封面" />-->
        <!--        </el-form-item>-->
        <el-form-item label="创作时间" prop="makeTime">
          <el-input v-model="form.makeTime" placeholder="请输入创作时间（例：2020-12-01）" />

        </el-form-item>
        <el-form-item label="曲目故事/简介" prop="musicDesc">
          <el-input v-model="form.musicDesc" placeholder="请输入曲目故事/简介" />
        </el-form-item>
        <el-form-item label="曲目风格标签" prop="styleLabel">
          <el-input v-model="form.styleLabel" placeholder="请输入曲目风格标签" />
        </el-form-item>
        <el-form-item label="pdf乐谱">
          <!-- <file-upload :fileType="pdfType" :fileSize="fileSize" v-model="form.pdfContent" :action="upUrlT"/> -->

          <el-upload class="upload-demo" :action="upUrlT" name="multipartFile" 
          :fileType="pdfType" :fileSize="fileSize" ref="uploadComp"
          :on-change="onChangeFile" v-model="form.pdfContent"
          :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" :limit="2"
          :on-exceed="handleExceed" :on-success="hanldeSuccess6" :headers="headers" :show-file-list="true"
          :auto-upload="true">
          <el-button type="warning" plain icon="el-icon-upload" size="mini" @click="handleImportMusic">pdf乐谱</el-button>
        </el-upload>
          <!--          <editor v-model="form.pdfContent" :min-height="192"/>-->
        </el-form-item>
        <el-form-item label="是否会员可见" prop="onlyVipShow">
          <!--          <el-input v-model="form.onlyVipShow" placeholder="请输入是否会员可见" />-->
          <el-radio-group v-model="form.onlyVipShow">
            <el-radio :label="1">是</el-radio>
            <el-radio :label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="乐谱是否会员可下载" prop="onlyVipDown">
          <!--          <el-input v-model="form.onlyVipDown" placeholder="请输入乐谱是否会员可下载" />-->
          <el-radio-group v-model="form.onlyVipDown">
            <el-radio :label="1">是</el-radio>
            <el-radio :label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="评测是否会员可用" prop="onlyTester">
          <!--          <el-input v-model="form.onlyTester" placeholder="请输入是否评测师傅会员可用" />-->
          <el-radio-group v-model="form.onlyTester">
            <el-radio :label="1">是</el-radio>
            <el-radio :label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>

        <el-form-item label="音频" prop="musicWav">
          <!--          <el-input v-model="form.musicWav" placeholder="请输入音频" />-->
          <!-- <file-upload :fileType="musicType" :fileSize="fileSize" v-model="form.musicWav" :action="upUrlT"/> -->
          <el-upload class="upload-demo" :action="upUrlT" name="multipartFile" 
          :fileType="musicType" :fileSize="fileSize" ref="uploadComp1"
          :on-change="onChangeFile" v-model="form.musicWav"
          :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" :limit="2"
          :on-exceed="handleExceed" :on-success="hanldeSuccess5" :headers="headers" :show-file-list="true"
          :auto-upload="true">
          <el-button type="warning" plain icon="el-icon-upload" size="mini" @click="handleImportMusic">横屏json文件</el-button>
        </el-upload>
        </el-form-item>
        <el-form-item label="横屏json文件" prop="horizontalJson">
          <!--          <el-input v-model="form.horizontalJson" placeholder="请输入横屏json文件" />-->
          <!-- <file-upload :fileType="jsonFileType" :fileSize="fileSize" v-model="form.horizontalJson" :action="upUrlT"/> -->
          <el-upload class="upload-demo" :action="upUrlT" name="multipartFile" 
          :fileType="jsonFileType" :fileSize="fileSize" ref="uploadComp2"
          :on-change="onChangeFile" v-model="form.horizontalJson"
          :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" :limit="2"
          :on-exceed="handleExceed" :on-success="hanldeSuccess4" :headers="headers" :show-file-list="true"
          :auto-upload="true">
          <el-button type="warning" plain icon="el-icon-upload" size="mini" @click="handleImportMusic">横屏json文件</el-button>
        </el-upload>

        </el-form-item>
        <el-form-item label="竖屏json文件" prop="verticalJson">
          <!--          <el-input v-model="form.verticalJson" placeholder="请输入竖屏json文件" />-->
          <!-- <file-upload :fileType="jsonFileType" :fileSize="fileSize" v-model="form.verticalJson" :action="upUrlT"/> -->
          <el-upload class="upload-demo" :action="upUrlT" name="multipartFile" 
          :fileType="jsonFileType" :fileSize="fileSize" ref="uploadComp3"
          :on-change="onChangeFile" v-model="form.verticalJson"
          :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" :limit="2"
          :on-exceed="handleExceed" :on-success="hanldeSuccess3" :headers="headers" :show-file-list="true"
          :auto-upload="true">
          <el-button type="warning" plain icon="el-icon-upload" size="mini" @click="handleImportMusic">竖屏json文件</el-button>
        </el-upload>

        </el-form-item>
        <el-form-item label="给SDK用的 musicxml" prop="musicForSdk">
          <!--          <el-input v-model="form.musicForSdk" placeholder="请输入给SDK用的 musicxml" />-->
          <!-- <file-upload :fileType="jsonFilesType" :fileSize="fileSize" v-model="form.musicForSdk" :action="upUrlT"/> -->
          <el-upload class="upload-demo" :action="upUrlT" name="multipartFile" 
          :fileType="jsonFileType" :fileSize="fileSize" ref="uploadComp4"
          :on-change="onChangeFile" v-model="form.musicForSdk"
          :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" :limit="2"
          :on-exceed="handleExceed" :on-success="hanldeSuccess2" :headers="headers" :show-file-list="true"
          :auto-upload="true">
          <el-button type="warning" plain icon="el-icon-upload" size="mini" @click="handleImportMusic">musicxml</el-button>
        </el-upload>
        </el-form-item>
        <el-form-item label="横板封面" prop="horizontalImg">
          <!--          <el-input v-model="form.horizontalImg" placeholder="请输入横板封面" />-->
          <!-- <image-upload v-model="form.horizontalImg" :limit="1" :action="upUrlT"/> -->
          <el-upload class="upload-demo" :action="upUrlT" name="multipartFile" 
          :on-change="onChangeFile" v-model="form.horizontalImg" ref="uploadComp5"
          :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" :limit="2"
          :on-exceed="handleExceed" :on-success="hanldeSuccess1" :headers="headers" :show-file-list="true"
          :auto-upload="true">
          <el-button type="warning" plain icon="el-icon-upload" size="mini" @click="handleImportMusic">横板封面</el-button>
        </el-upload>
        </el-form-item>
        <el-form-item label="竖版封面" prop="verticalImg">
          <!--          <el-input v-model="form.verticalImg" placeholder="请输入竖版封面" />-->
          <!-- <image-upload v-model="form.verticalImg" :limit="1" :action="upUrlT"/> -->
          <el-upload class="upload-demo" :action="upUrlT" name="multipartFile" 
          :on-change="onChangeFile" v-model="form.verticalImg" ref="uploadComp6"
          :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" :limit="2"
          :on-exceed="handleExceed" :on-success="hanldeSuccess" :headers="headers" :show-file-list="true"
          :auto-upload="true">
          <el-button type="warning" plain icon="el-icon-upload" size="mini" @click="handleImportMusic">竖版封面</el-button>
        </el-upload>
        </el-form-item>
        <el-form-item label="操作人" prop="operatorUser">
          <el-input v-model="form.operatorUser" disabled="disabled" placeholder="" />
        </el-form-item>
        <el-form-item label="操作时间" prop="operatorTime">
          <el-date-picker clearable disabled="disabled" v-model="form.operatorTime" type="date" value-format="yyyy-MM-dd"
            placeholder="">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button v-if="!isView" type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listMusicinfo, getMusicinfo, delMusicinfo, addMusicinfo, updateMusicinfo,getVirtualUser } from "@/api/system/musicinfo";
import { getToken } from "../../../utils/auth";
import axios from 'axios';
export default {
  name: "Musicinfo",
  data() {
    return {
      
      // upUrl: process.env.VUE_APP_BASE_API + '/system/musicinfo/importMusicInfo',
      upUrl: process.env.VUE_APP_BASE_API + '/v1/app/public/upload/music',
      upUrlT: process.env.VUE_APP_BASE_API + '/v1/app/public/upload',
      headers: {
        Authorization: "Bearer " + getToken(),
      },
      isFlag:false,
      // open:false,
      multipartFileList: [],
      pdfType: ['pdf'],
      musicType: ['wav'],
      jsonFileType: ['json'],
      jsonFilesType: ['musicxml'],
      sdkFileType: ['musicxml'],
      fileSize: 100,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      isView: false,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 乐曲信息表格数据
      musicinfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,

      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        musicName: null,
        ranks: null,
        musicMaker: null,
        musicIndex: null,
        img: null,
        makeTime: null,
        musicDesc: null,
        styleLabel: null,
        pdfContent: null,
        onlyVipShow: null,
        onlyVipDown: null,
        onlyTester: null,
        operatorUser: null,
        operatorTime: null,
        musicWav: null,
        horizontalJson: null,
        verticalJson: null,
        musicForSdk: null,
        horizontalImg: null,
        verticalImg: null,
        status: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      arrayUser:{},
      arrayUserInfo:{
        pageNum: 1,
        pageSize: 10,
        name:null,
        type:null,
      },
      userName:null,
      opens:false
    };
  },
  created() {
    this.getList();
    this.userInfo()
  },
  methods: {
    /** 查询乐曲信息列表 */
    getList() {
      this.loading = true;
      listMusicinfo(this.queryParams).then(response => {
        this.musicinfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    userInfo(){
      this.loading = true;
      if(this.arrayUserInfo.type == '01'){
        getVirtualUser(this.arrayUserInfo).then(res =>{
        this.arrayUser = res.rows
        this.loading = false;
      })
      }else{
        getVirtualUser(this.arrayUserInfo).then(res =>{
        this.arrayUser = res.rows
        this.loading = false;
      })
    }
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
      this.$refs.uploadComp.clearFiles()
      this.$refs.uploadComp1.clearFiles()
      this.$refs.uploadComp2.clearFiles()
      this.$refs.uploadComp3.clearFiles()
      this.$refs.uploadComp4.clearFiles()
      this.$refs.uploadComp5.clearFiles()
      this.$refs.uploadComp6.clearFiles()
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        musicName: null,
        musicMaker: null,
        musicIndex: null,
        ranks: null,
        img: null,
        makeTime: null,
        musicDesc: null,
        styleLabel: null,
        pdfContent: null,
        onlyVipShow: null,
        onlyVipDown: null,
        onlyTester: null,
        operatorUser: null,
        operatorTime: null,
        musicWav: null,
        horizontalJson: null,
        verticalJson: null,
        musicForSdk: null,
        horizontalImg: null,
        verticalImg: null,
        status: null
      };
      this.isView = false
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },

    handleSelectionChanges(selection) {
      this.userName = selection.map(item => item.nickName)

    },
    addToBookAction(){
      this.opens = false
    },


    handleAdds(){
      // handleAdd() {
      // this.reset();
      this.opens = true;
      this.title = "上传音乐包";
      // this.getList()
    // },
    },


    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加乐曲信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getMusicinfo(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改乐曲信息";
      });
    },
    handleView(row) {
      this.reset();
      this.isView = true
      const id = row.id
      getMusicinfo(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "乐曲信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateMusicinfo(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addMusicinfo(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              
              this.$refs.uploadComp.clearFiles()
      this.$refs.uploadComp1.clearFiles()
      this.$refs.uploadComp2.clearFiles()
      this.$refs.uploadComp3.clearFiles()
      this.$refs.uploadComp4.clearFiles()
      this.$refs.uploadComp5.clearFiles()
      this.$refs.uploadComp6.clearFiles()
      this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除乐曲信息编号为"' + ids + '"的数据项？').then(function () {
        return delMusicinfo(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/musicinfo/export', {
        ...this.queryParams
      }, `musicinfo_${new Date().getTime()}.xlsx`)
    },


    /**导入曲目**/
    handleImportMusic() {
      
      console.log("~~@@@@@@~~~~~")
    },
    handleRemove(multipartFile, multipartFileList) {
      console.log(multipartFile, multipartFileList);
    },
    handlePreview(multipartFile) {
      console.log(multipartFile);
    },
    handleExceed(multipartFiles, multipartFileList) {
      this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${multipartFiles.length} 个文件，共选择了 ${multipartFiles.length + multipartFileList.length} 个文件`);
    },
    beforeRemove(multipartFile, multipartFileList) {
      return this.$confirm(`确定移除 ${multipartFile.name}？`);
    },
    hanldeSuccess(res,multipartFile, multipartFileList) {
      if(res.code == 200){
        this.form.verticalImg = res.data.url
      }
      this.getList()
    },
    hanldeSuccess1(res,multipartFile, multipartFileList) {
      if(res.code == 200){
        this.form.horizontalImg = res.data.url
      }
      this.getList()
    },
    hanldeSuccess2(res,multipartFile, multipartFileList) {
      if(res.code == 200){
        this.form.musicForSdk = res.data.url
      }
      this.getList()
    },
    hanldeSuccess3(res,multipartFile, multipartFileList) {
      if(res.code == 200){
        this.form.verticalJson = res.data.url
        
      }
      this.getList()
    },
    hanldeSuccess4(res,multipartFile, multipartFileList) {
      if(res.code == 200){
        this.form.horizontalJson = res.data.url
        
      }
      this.getList()
    },
    hanldeSuccess5(res,multipartFile, multipartFileList) {
      if(res.code == 200){
        this.form.musicWav = res.data.url
      }
      this.getList()
    },
    hanldeSuccess6(res,multipartFile, multipartFileList) {
      if(res.code == 200){
        this.form.pdfContent = res.data.url
        
      }
      this.getList()
    },
    onChangeFile(multipartFile, multipartFileList) {
      if (multipartFileList.length > 1 && multipartFile.status !== "fail") {
        multipartFileList.splice(0, 1);
      }

    }, statusFormatter(row) {
      if (row.status == 1) {
        return '在线'
      }
      else {
        return ''
      }
    }, vipshowFormatter(row) {
      if (row.onlyVipShow == 1) {
        return '是'
      }
      else {
        return '否'
      }
    }, vipdownFormatter(row) {
      if (row.onlyVipDown == 1) {
        return '是'
      }
      else {
        return '否'
      }
    }, onlyTesterFormatter(row) {
      if (row.onlyTester == 1) {
        return '是'
      } else {
        return '否'
      }
    }
  }
};
</script>
